package com.example.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

@Service
public class TtsService
{
    private String endData;
    @Value("${the-server.ip}")
    private String serverIp;
    private String theUrl;
    public String change(String txt)
    {
        theUrl="http://"+serverIp+":8081?pwd=7523&txt=";
        System.out.println(theUrl);
        OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url(theUrl+txt)
                .build();
        try (Response response = client.newCall(request).execute())
        {
            endData=response.body().string();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return endData;
    }
}
